<?php
if (function_exists ( '__autoload' )) {
	trigger_error ( "GroupSNS: It looks like your code is using an __autoload() 
			function. GroupSNS uses spl_autoload_register() which will bypass 
			your __autoload() function and may break autoloading.", E_USER_WARNING );
}
$loader = new Loader ();
spl_autoload_register ( array (
		$loader,
		'autoloader' 
) );
define ( 'FW_DIR', dirname ( __FILE__ ) );
class Loader {
	/**
	 * <h2>框架的自动加载方法</h2>
	 * <p>负责整个框架中类的加载</p>
	 *
	 * @param string $className        	
	 */
	public function autoloader($className) {
		if (array_key_exists ( $className, $this->_classes )) {
			include_once FW_DIR . $this->_classes [$className];
			return true;
		} else {
			return false;
		}
	}
	
	/**
	 * <h2>框架中类路径的数组</h2>
	 * <p>数组存放类的路径，数组下标是类名，数组值是对应的路径，<br />
	 * 这里的路径一般是相对于${__FILE__}的路径
	 * </p>
	 *
	 * @var array
	 */
	protected $_classes = array (
			// core
			'Core' => '/core/Core.class.php',
			'URIParser' => '/core/URIParser.class.php',
			// basics
			'ExceptionEx' => '/basics/ExceptionEx.class.php', // 框架异常类
			'Request' => '/basics/Request.class.php', // 请求封装类
			'SessionManager' => '/basics/SessionManager.class.php', // 会话管理类
			'IAction' => '/basics/IAction.class.php', // Action接口
			'IView' => '/basics/IView.class.php', // View接口
			'ActionListener' => '/basics/ActionListener.class.php',
			
			// datatype
			'IDataType' => '/datatype/IDataType.class.php',
			'IAccess' => '/datatype/IAccess.class.php',
			'ISanitize' => '/datatype/ISanitize.class.php',
			'IValidate' => '/datatype/IValidate.class.php',
			'AccessImpl' => '/datatype/AccessImpl.class.php',
			'CARRAY' => '/datatype/CARRAY.class.php',
			'CBOOL' => '/datatype/CBOOL.class.php',
			'CEMAIL' => '/datatype/CEMAIL.class.php',
			'CFLOAT' => '/datatype/CFLOAT.class.php',
			'CINT' => '/datatype/CINT.class.php',
			'CSTRING' => '/datatype/CSTRING.class.php',
			'CMAP' => '/datatype/CMAP.class.php',
			'CLIST' => '/datatype/CLIST.class.php',
			'CSET'=>'/datatype/CSET.class.php'
	);
}